import QtQuick 1.1

 
Rectangle {
    width: theMap.width + startCalc.width
    height: theMap.height
    color: "lightgray"
    id: rootObject
    
 	function updatePathImage() {
 		console.log("view.qml: updatePathImage called")
 		//thePath.source = ""
 		thePath.source = "image://path/path" + Math.floor((Math.random()*10000000)+1);
 		}
 		
 	Image {
 		id: theMap
 		source: "summoners2-0rift205364x4310-20.jpg"
 		z:0
 		}
 	Image {
 		id: thePath
 		source: "image://path/path"
 		cache: false
 		z:1
 		}
 	Image {
 		id: redPin
 		source: "pin-red.png"
 		x: 100
 		y: 100
 		z: 2
 		}
 	Image {
 		id: greenPin
 		source: "pin-green.png"
 		x: 200
 		y: 200
 		z: 2
 		}
 	Rectangle {
 		id: startCalc
 		color: "black"
 		anchors.left: theMap.right
 		width: 100
 		height: 40
 		Text {
 			anchors.centerIn: parent.Center
 			text: "Calc"
 			color: "white"
 		}
 		MouseArea {
 			anchors.fill: parent
 			onClicked: pathfinder.updatePath()
 			}
 	}
 	MouseArea {
 		id: mouseMap
 		anchors.fill: theMap
 		acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
 		onClicked: {
 			console.log(mouse.button)
 			if (mouse.button == Qt.LeftButton) { 
 				redPin.x = mouseX - 20
 				redPin.y = mouseY - 35
 				pathfinder.setStart(mouseX,mouseY)
 				}
 			if (mouse.button == Qt.RightButton) {
 				greenPin.x = mouseX - 19
 				greenPin.y = mouseY - 35
 				pathfinder.setEnd(mouseX,mouseY)
 				}
 			if (mouse.button == Qt.MiddleButton) {
 				console.log("mid")
 				pathfinder.updatePath()
 				//thePath.source = "image://path/path"
 				}
 			}
 		}
}